<template>
  <div>
    <van-loading
      size="24px"
      color="#0094ff"
      vertical
      v-if="loading"
    >加载中...</van-loading>
    <div v-if="!loading">

      <div style="padding:25px;background: #70b0eb;">
        <van-row>
          <van-col span="7">
            <div style="padding-left:20px">
              <van-image
                fit="cover"
                width="50px"
                height="50px"
                :src="require('./icon/head.png')"
              />
            </div>
          </van-col>
          <van-col span="11">
            <div>
              
              <van-row style="color:#FFF;font-size: 20px;margin-top: -5px;">
              {{name}}
              </van-row>
              <van-row style="color:#FFF;font-size: 20px;">
               江南布衣
              </van-row>
            </div>
          </van-col>
        </van-row>
       
      </div>
      <div style="padding:30px;">
        <van-grid
          :border="false"
          :column-num="4"
        >
          <van-grid-item @click="toSearch">
            <van-image
              fit="cover"
              width="50px"
              height="50px"
              src="https://img.alicdn.com/imgextra/i4/O1CN01HGhduk1a3XUaa2jbf_!!6000000003274-2-tps-198-200.png"

            />
            <span style="margin-top:5px;color: #7eafe6;">档案查询</span>
          </van-grid-item>
          <van-grid-item @click="tophoto">
            <van-image
              fit="cover"
              width="50px"
              height="50px"
              src="https://img.alicdn.com/imgextra/i2/O1CN012LNsyu1lbOXdNPEae_!!6000000004837-2-tps-198-200.png"

            />
            <span style="margin-top:5px;color: #7eafe6;">图片上传</span>

          </van-grid-item>

        </van-grid>
      </div>
    </div>
  </div>

</template>
<script>
import * as dd from 'dingtalk-jsapi'
import { Notify } from 'vant'

export default {
  data() {
    return {
      name: '',
      loading: false
    }
  },
  mounted() {
    // localStorage.setItem('jobNumber', 24662)

    // localStorage.setItem('jobNumber', 17830)

    // this.loadData()
    let that = this
    dd.ready(function () {
      dd.runtime.permission
        .requestAuthCode({
          corpId: 'ding8bac6beff1d2d841', // 企业id
          onSuccess: function (info) {
            let code = info.code // 通过该免登授权码可以获取用户身份
            that
              .$http({
                url: '/api/gateway/basemgt-emp/login/dingtalk',
                method: 'post',
                params: {
                  code: code,
                  agentId: '262740780'
                },
                data: {
                  code: code,
                  agentId: '262740780'
                }
              })
              .then(data => {
                if (data.success) {
                      that.name = data.data.name
                      localStorage.setItem('jobNumber', data.data.jobNumber)
                    } else if (data.data == null) {
                      that.$toast(data.msg)
                    } else {
                      that.$toast(data.msg)
                    }
              })
          },
          onFail: function (err) {}
        })
        .catch(err => {
          console.log(err)
          alert(err)
        })
    })
  },
  computed: {
    jobNumber() {
      return localStorage.getItem('jobNumber')
    }
  },
  created: function () {
    document.title = '辅料'
  },
  methods: {
    toSearch() {
      this.$router.push({ path: 'search'})
    },
    tophoto() {
      this.$router.push({ path: 'photo'})
    },
    toList(num) {
      this.$router.push({ path: 'list', query: { type: num } })
    },
    toInt(){
      this.$router.push({ path: 'integrate' })
    },
    toAll() {
      this.$router.push({ path: 'all' })
    }
  }
}
</script>

<style scoped>
.number {
  color: #70b0eb;
  font-size: 30px;
  font-family: 'vant-icon';
}
.van-loading {
  top: 100px;
}
</style>>
